package cn.edu.zut.project1.enums;

/**
 *商品分类枚举（ID对应数据库category表的id字段）
 */

public enum ProductCategoryEnum {
    BOOK(1, "书籍教材"),
    ELECTRONIC(2, "电子产品"),
    DAILY(3, "生活用品"),
    SPORT(4, "运动器材"),
    FOOD(5, "食品"),
    OTHER(6, "其他");

    private final Integer id;
    private final String name;

    ProductCategoryEnum(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public static String getNameByID(Integer id){
        for(ProductCategoryEnum category : values()){
            if(category.id.equals(id)){
                return category.name;
            }
        }
        return "未知分类";
    }

}
